<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>bui.loader</title>
    <!-- <link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css"> -->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="../assets/css/cssgrids-min.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
    <!-- <script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script> -->
    <script src="../assets/js/jquery-1.9.1.min.js"></script>
    <script src="../assets/js/index.js"></script>
    <script src="../assets/js/yui-min.js"></script>
    <script src="../assets/js/combo/oop-min.js"></script>
    <script src="../assets/js/combo/array-extras-min.js"></script>
    <script src="../assets/js/combo/autocomplete.js"></script>
    <script src="../assets/js/combo/history-base-min.js"></script>
</head>
<body class="yui3-skin-sam">
<div id="sidemenu" class="sidebar-menu">菜单</div>
<div id="doc">
    <div id="hd" class="yui3-g header">
        <div class="yui3-u-3-4">
            
                <h1><a href="../index.html"><img src="../assets/css/logo.png" title="" width="30px"></a>
                <a href="../index.html">BUI</a>
                
                </h1>
            
            <p class="off-left">其它版本:<select name="" id="" onchange="window.location.href=this.value"><option value="../api/index.html" selected>1.5.0</option><option value="../api-1.4.8/index.html">1.4.8</option></select></p>
            <p class="off-left" style="font-size:12px;margin-right: 15px;">API for BUI 1.5.4 </p>
            
        </div>
    </div>
    <div id="bd" class="yui3-g">

        <div id="sidebar" class="yui3-u-1-4">
            <div id="docs-sidebar" class="sidebar apidocs">
                <div id="api-list">
    <div id="api-tabview" class="tabview">

        <ul class="tabs">
            <li><a href="#api-classes">Classes</a></li>
            <li><a href="#api-modules">Modules</a></li>
        </ul>

        <div id="api-tabview-filter">
            <input type="search" id="api-filter" placeholder="Type to filter APIs">
        </div>

        <div id="api-tabview-panel">
            <ul id="api-classes" class="apis classes">
            
                <li><a href="../classes/bui.accordion.html">bui.accordion</a></li>
            
                <li><a href="../classes/bui.actionsheet.html">bui.actionsheet</a></li>
            
                <li><a href="../classes/bui.ajax.html">bui.ajax</a></li>
            
                <li><a href="../classes/bui.alert.html">bui.alert</a></li>
            
                <li><a href="../classes/bui.all.html">bui.all</a></li>
            
                <li><a href="../classes/bui.animate.html">bui.animate</a></li>
            
                <li><a href="../classes/bui.array.html">bui.array</a></li>
            
                <li><a href="../classes/bui.back.html">bui.back</a></li>
            
                <li><a href="../classes/bui.btn.html">bui.btn</a></li>
            
                <li><a href="../classes/bui.config.html">bui.config</a></li>
            
                <li><a href="../classes/bui.confirm.html">bui.confirm</a></li>
            
                <li><a href="../classes/bui.delete.html">bui.delete</a></li>
            
                <li><a href="../classes/bui.dialog.html">bui.dialog</a></li>
            
                <li><a href="../classes/bui.download.html">bui.download</a></li>
            
                <li><a href="../classes/bui.dropdown.html">bui.dropdown</a></li>
            
                <li><a href="../classes/bui.emitter.html">bui.emitter</a></li>
            
                <li><a href="../classes/bui.file.html">bui.file</a></li>
            
                <li><a href="../classes/bui.fileselect.html">bui.fileselect</a></li>
            
                <li><a href="../classes/bui.get.html">bui.get</a></li>
            
                <li><a href="../classes/bui.getPageParams.html">bui.getPageParams</a></li>
            
                <li><a href="../classes/bui.guid.html">bui.guid</a></li>
            
                <li><a href="../classes/bui.hint.html">bui.hint</a></li>
            
                <li><a href="../classes/bui.init.html">bui.init</a></li>
            
                <li><a href="../classes/bui.input.html">bui.input</a></li>
            
                <li><a href="../classes/bui.levelselect.html">bui.levelselect</a></li>
            
                <li><a href="../classes/bui.list.html">bui.list</a></li>
            
                <li><a href="../classes/bui.listview.html">bui.listview</a></li>
            
                <li><a href="../classes/bui.load.html">bui.load</a></li>
            
                <li><a href="../classes/bui.loader.html">bui.loader</a></li>
            
                <li><a href="../classes/bui.loading.html">bui.loading</a></li>
            
                <li><a href="../classes/bui.mask.html">bui.mask</a></li>
            
                <li><a href="../classes/bui.number.html">bui.number</a></li>
            
                <li><a href="../classes/bui.pickerdate.html">bui.pickerdate</a></li>
            
                <li><a href="../classes/bui.platform.html">bui.platform</a></li>
            
                <li><a href="../classes/bui.post.html">bui.post</a></li>
            
                <li><a href="../classes/bui.prompt.html">bui.prompt</a></li>
            
                <li><a href="../classes/bui.pullrefresh.html">bui.pullrefresh</a></li>
            
                <li><a href="../classes/bui.put.html">bui.put</a></li>
            
                <li><a href="../classes/bui.rating.html">bui.rating</a></li>
            
                <li><a href="../classes/bui.ready.html">bui.ready</a></li>
            
                <li><a href="../classes/bui.refresh.html">bui.refresh</a></li>
            
                <li><a href="../classes/bui.router.html">bui.router</a></li>
            
                <li><a href="../classes/bui.run.html">bui.run</a></li>
            
                <li><a href="../classes/bui.scroll.html">bui.scroll</a></li>
            
                <li><a href="../classes/bui.searchbar.html">bui.searchbar</a></li>
            
                <li><a href="../classes/bui.select.html">bui.select</a></li>
            
                <li><a href="../classes/bui.sidebar.html">bui.sidebar</a></li>
            
                <li><a href="../classes/bui.slide.html">bui.slide</a></li>
            
                <li><a href="../classes/bui.stepbar.html">bui.stepbar</a></li>
            
                <li><a href="../classes/bui.storage.html">bui.storage</a></li>
            
                <li><a href="../classes/bui.store.html">bui.store</a></li>
            
                <li><a href="../classes/bui.swipe.html">bui.swipe</a></li>
            
                <li><a href="../classes/bui.tab.html">bui.tab</a></li>
            
                <li><a href="../classes/bui.typeof.html">bui.typeof</a></li>
            
                <li><a href="../classes/bui.unit.html">bui.unit</a></li>
            
                <li><a href="../classes/bui.upload.html">bui.upload</a></li>
            
                <li><a href="../classes/bui.viewport.html">bui.viewport</a></li>
            
            </ul>

            <ul id="api-modules" class="apis modules">
            
                <li><a href="../modules/Animate.html">Animate</a></li>
            
                <li><a href="../modules/Core.html">Core</a></li>
            
                <li><a href="../modules/Event.html">Event</a></li>
            
                <li><a href="../modules/Method.html">Method</a></li>
            
                <li><a href="../modules/Native.html">Native</a></li>
            
                <li><a href="../modules/UI.html">UI</a></li>
            
            </ul>
        </div>
    </div>
</div>
 
            </div>
        </div>
        <div class="yui3-u-3-4">
                <div id="api-options">
        Show:
        <label for="api-show-inherited">
            <input type="checkbox" id="api-show-inherited" checked>
            Inherited
        </label>

        <label for="api-show-protected">
            <input type="checkbox" id="api-show-protected">
            Protected
        </label>

        <label for="api-show-private">
            <input type="checkbox" id="api-show-private">
            Private
        </label>
        <label for="api-show-deprecated">
            <input type="checkbox" id="api-show-deprecated">
            Deprecated
        </label>

    </div>


            <div class="apidocs">
                <div id="docs-main">
                    <div class="content">
                        <h1>bui.loader Class</h1>
<div class="box meta">
    

    

    
        <div class="foundat">
            Defined in: <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l10"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:10</code></a>
        </div>
    

    
        
            Module: <a href="../modules/Core.html">Core</a>
        
    

    
        <p>Available since 1.4.0</p>
    
</div>



<div class="box intro">
    <p><h2>模块加载器</h2></p>
<p><p>模块加载器, 默认已经初始化给 window.loader, 无需再次初始化. </p></p>
<p><p>可以直接调用 loader.define, loader.require 或者 loader.map 等方法</p></p>
<p><p>主要配合 router 的单页模块加载. </p><h3>预览地址: <a href="../../index.html#pages/ui_loader/index.html" target="_blank">demo</a></h3></p>
<p><h3>方法说明:</h3>
<a href="../classes/bui.loader.html#method_define" class="crosslink">define</a>: 模块定义<br>
<a href="../classes/bui.loader.html#method_require" class="crosslink">require</a>: 加载模块 <br>
<a href="../classes/bui.loader.html#method_map" class="crosslink">map</a>: 模块声明,基本路径配置 <br>
<a href="../classes/bui.loader.html#method_import" class="crosslink">import</a>: 加载动态脚本资源及CSS资源 <br>
<a href="../classes/bui.loader.html#method_checkLoad" class="crosslink">checkLoad</a>: 检查是否所有模块都已经实例化 <br></p>

</div>


    <div class="constructor">
        <h2>Constructor</h2>
        <div id="method_bui.loader" class="method item">
    <h3 class="name"><code>bui.loader</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code class="optional">[option]</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l10"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:10</code></a>
        
        </p>


        

        
            <p>Available since 1.4.0</p>
        
    </div>

    <div class="description">
        
    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name optional">[option]</code>
                        <span class="type">Object</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                         
                    </div>

                    
                        <ul class="params-list">
                            
                            <li class="param">
                                
                                    <code class="param-name">cache</code>
                                    <span class="type">Boolean</span>
                                

                                <div class="param-description">
                                    <p>[默认: true, 浏览器缓存脚本 | false, 不缓存 ]</p>

                                </div>

                                
                            </li>
                            
                            <li class="param">
                                
                                    <code class="param-name">scriptSuffix</code>
                                    <span class="type">Boolean</span>
                                

                                <div class="param-description">
                                    <p>[默认: &quot;.js&quot;, 一般无需更改 ]</p>

                                </div>

                                
                            </li>
                            
                        </ul>
                    
                </li>
            
            </ul>
        </div>
    

    

    
        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                <pre class="code prettyprint"><code>   // 默认已经初始化,无需再次初始化, 如果要修改,应该在 window.router 前面.
   window.loader = bui.loader();</code></pre>

            </div>
        </div>
    
</div>

    </div>


<div id="classdocs" class="tabview">
    <ul class="api-class-tabs">
        <li class="api-class-tab index"><a href="#index">Index</a></li>

        
            <li class="api-class-tab methods"><a href="#methods">Methods</a></li>
        
        
        
        
            <li class="api-class-tab events"><a href="#events">Events</a></li>
        
    </ul>

    <div>
        <div id="index" class="api-class-tabpanel index">
            <h2 class="off-left">Item Index</h2>

            
                <div class="index-section methods">
                    <h3>Methods</h3>

                    <ul class="index-list methods">
                        
                            <li class="index-item method">
                                <a href="#method_checkLoad">checkLoad</a>

                                
                                
                            </li>
                        
                            <li class="index-item method">
                                <a href="#method_define">define</a>

                                
                                
                            </li>
                        
                            <li class="index-item method">
                                <a href="#method_destroy">destroy</a>

                                
                                
                            </li>
                        
                            <li class="index-item method">
                                <a href="#method_get">get</a>

                                
                                
                            </li>
                        
                            <li class="index-item method">
                                <a href="#method_import">import</a>

                                
                                
                            </li>
                        
                            <li class="index-item method">
                                <a href="#method_map">map</a>

                                
                                
                            </li>
                        
                            <li class="index-item method">
                                <a href="#method_require">require</a>

                                
                                
                            </li>
                        
                            <li class="index-item method">
                                <a href="#method_set">set</a>

                                
                                
                            </li>
                        
                    </ul>
                </div>
            

            

            

            
                <div class="index-section events">
                    <h3>Events</h3>

                    <ul class="index-list events">
                        
                            <li class="index-item event">
                                <a href="#event_off">off</a>

                                
                                
                            </li>
                        
                            <li class="index-item event">
                                <a href="#event_on">on</a>

                                
                                
                            </li>
                        
                            <li class="index-item event">
                                <a href="#event_trigger">trigger</a>

                                
                                
                            </li>
                        
                    </ul>
                </div>
            
        </div>

        
            <div id="methods" class="api-class-tabpanel">
                <h2 class="off-left">Methods</h2>

                
                    <div id="method_checkLoad" class="method item">
    <h3 class="name"><code>checkLoad</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code class="optional">[option]</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    
        <span class="returns-inline">
            <span class="type">Boolean</span>
        </span>
    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l850"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:850</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>检测模块的加载状态,加载完成,该模块会有一个export对象,就是callback的回调</p>
    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name optional">[option]</code>
                        <span class="type">Object</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                         
                    </div>

                    
                        <ul class="params-list">
                            
                            <li class="param">
                                
                                    <code class="param-name optional">[modules]</code>
                                    <span class="type">Array</span>
                                    <span class="flag optional" title="This parameter is optional.">optional</span>
                                

                                <div class="param-description">
                                    <p>[ 模块名称, 如果不传,则检测所有加载的模块 ]</p>

                                </div>

                                
                            </li>
                            
                        </ul>
                    
                </li>
            
            </ul>
        </div>
    

    
        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                
                    
                        <span class="type">Boolean</span>:
                    
                    <p>[ 全部创建完成以后会返回 true ]</p>

                
            </div>
        </div>
    

    
        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                <pre class="code prettyprint"><code>       例子1: 检测所有模块是否都加载完毕

       var bool = loader.checkLoad([&quot;main&quot;]);
       console.log(bool)</code></pre>

            </div>
        </div>
    
</div>

                
                    <div id="method_define" class="method item">
    <h3 class="name"><code>define</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code class="optional">[moduleName]</code>
                    
                </li>
            
                <li class="arg">
                    
                        <code class="optional">[depend]</code>
                    
                </li>
            
                <li class="arg">
                    
                        <code>callback</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    
        <span class="returns-inline">
            <span class="type">Object</span>
        </span>
    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l269"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:269</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>define是bui.loader实例的一个方法,用于定义模块, 1.5.3新增定义页面的生命周期</p>
<p>一个js对应一个 define ,可以定义一个匿名的模块,或者自定义依赖的模块,用法跟requirejs类似,</p>
<p>自定义模块名以后,需要用map声明该模块的script属性,或者callback方法</p>
    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name optional">[moduleName]</code>
                        <span class="type">String | Object</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                        <p>[模块的自定义名称,可以省略, 如果是定义该模块的生命周期,参考例子5. 1.5.3新增. ]</p>

                    </div>

                    
                </li>
            
                <li class="param">
                    
                        <code class="param-name optional">[depend]</code>
                        <span class="type">Array</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                        <p>[模块的依赖模块,可以省略, 模块名不含.js ]</p>

                    </div>

                    
                </li>
            
                <li class="param">
                    
                        <code class="param-name">callback</code>
                        <span class="type">Function</span>
                    

                    

                    <div class="param-description">
                        <p>[注册回调,如果有return值, 可以抛出给其它模块调用 ]</p>

                    </div>

                    
                </li>
            
            </ul>
        </div>
    

    
        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                
                    
                        <span class="type">Object</span>:
                    
                    <p>[ 返回值用于公共使用 ]</p>

                
            </div>
        </div>
    

    
        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                <pre class="code prettyprint"><code>   例子1: 注册首页的回调 pages/main/main.js
   提示: pages/main/main.js 文件, 定义了一个匿名模块,匿名模块的模块名取.js前面的路径名,确保唯一

   // 最简单的匿名定义 loader.define
   loader.define(function(require,exports,module){

       // require : 相当于 loader.require, 获取依赖的模块
       // module : 拿到当前模块信息

       // 可以通过 return 把希望给其它页面调用的方法抛出来
       return {

       }
   })

   例子2: 直接定义返回的对象, 模块名同样是路径名
   loader.define({
     test: &quot;console&quot;
   })

   例子3: 定义模块的依赖,如果模块未定义固定名称,则路径.html前面是默认的模块名称
   // require,exports,module 在依赖后面顺序下来,不是必须
   // 当前模块依赖于page2
   loader.define([&quot;pages/page2/page2&quot;],function(page2,require,exports,module){
       // 拿到依赖的模块,取名为page2
       console.log(page2)
       // 可以通过 return 把希望给其它页面调用的方法抛出来
       return {

       }
   })

   例子4: 定义一个自定义名称的模块
   // 当前模块名为 page2 , 则别的模块要依赖page2的时候,使用自定义的名称
   loader.define(&quot;page2&quot;,function(){
       // 可以通过 return 把希望给其它页面调用的方法抛出来
       return {

       }
   })

   // 需要在index.html 路由初始化前,先声明该模块的脚本,或者回调
   loader.map({
       moduleName: &quot;page2&quot;,
       template: &quot;pages/page2/page2.html&quot;,
       script: &quot;pages/page2/page2.js&quot;
   })

   例子5: 1.5.3新增 定义页面的生命周期
   loader.define({
       moduleName: &quot;&quot;,     // 是否是自定义的模块名, 没有则不要这个参数
       depend: [],         // 是否有依赖的模块, 没有则不要这个参数
       beforeCreate: function(){
           // 只在第一次创建的时候执行
           console.log(&quot;beforeCreate&quot;)
       },
       created: function(){
           // 只在第一次创建的时候执行
           console.log(&quot;beforeCreate&quot;)
       },
       beforeLoad: function(){
           // 每次跳转前执行, 注意:这里return false 并不能阻止页面跳转及执行, 如果要阻止应该在 bui.load({beforeLoad:function(){ return false; }})
           console.log(&quot;beforeCreate&quot;)
       },
       loaded: function(require,export,module){
           // 每次跳转时执行, loader.require 要加载当前模块,需要在这里抛出方法.
           console.log(&quot;loaded&quot;)
       },
       show: function(e){

           // 每次跳转,后退后执行
           console.log(e.type ,&quot;show&quot;)
       },
       hide: function(){
           // 每次跳转,后退后执行上一个页面的hide
           console.log(&quot;hide&quot;)
       },
       beforeDestroy: function(){
           // 每次后退前执行
           console.log(&quot;beforeDestroy&quot;)
       },
       destroyed: function(){
           // 每次后退后执行
           console.log(&quot;destroyed&quot;)
       }
   })</code></pre>

            </div>
        </div>
    
</div>

                
                    <div id="method_destroy" class="method item">
    <h3 class="name"><code>destroy</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code class="optional">[option]</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    
        <span class="returns-inline">
            <span class="type">Object</span>
        </span>
    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l234"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:234</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>销毁一个模块</p>
    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name optional">[option]</code>
                        <span class="type">Object</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                         
                    </div>

                    
                        <ul class="params-list">
                            
                            <li class="param">
                                
                                    <code class="param-name optional">[name]</code>
                                    <span class="type">String</span>
                                    <span class="flag optional" title="This parameter is optional.">optional</span>
                                

                                <div class="param-description">
                                    <p>[模块的自定义名称,可以省略,自定义模块名以后,需要用map声明该模块的script属性,或者callback方法 ]</p>

                                </div>

                                
                            </li>
                            
                            <li class="param">
                                
                                    <code class="param-name optional">[depend]</code>
                                    <span class="type">Array</span>
                                    <span class="flag optional" title="This parameter is optional.">optional</span>
                                

                                <div class="param-description">
                                    <p>[模块的依赖模块,可以省略, 模块名不含.js ]</p>

                                </div>

                                
                            </li>
                            
                            <li class="param">
                                
                                    <code class="param-name">callback</code>
                                    <span class="type">Function</span>
                                

                                <div class="param-description">
                                    <p>[注册回调,如果有return值, 可以抛出给其它模块调用 ]</p>

                                </div>

                                
                            </li>
                            
                        </ul>
                    
                </li>
            
            </ul>
        </div>
    

    
        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                
                    
                        <span class="type">Object</span>:
                    
                    <p>[ 返回值用于公共使用 ]</p>

                
            </div>
        </div>
    

    
        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                
            </div>
        </div>
    
</div>

                
                    <div id="method_get" class="method item">
    <h3 class="name"><code>get</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code>name</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    
        <span class="returns-inline">
            <span class="type">Object</span>
        </span>
    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l145"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:145</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>获取模块</p>
    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name">name</code>
                        <span class="type">String</span>
                    

                    

                    <div class="param-description">
                        <p>[通过模块名称,获取模块信息]</p>

                    </div>

                    
                </li>
            
            </ul>
        </div>
    

    
        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                
                    
                        <span class="type">Object</span>:
                    
                    <p>[description]</p>

                
            </div>
        </div>
    

    
        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                <pre class="code prettyprint"><code>       var main = loader.get(&quot;main&quot;)</code></pre>

            </div>
        </div>
    
</div>

                
                    <div id="method_import" class="method item">
    <h3 class="name"><code>import</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code class="optional">[option]</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    
        <span class="returns-inline">
            <span class="type">Boolean</span>
        </span>
    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l906"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:906</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>动态加载脚本资源,或者css资源,1.5.2 新增html的加载</p>
    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name optional">[option]</code>
                        <span class="type">Object</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                         
                    </div>

                    
                        <ul class="params-list">
                            
                            <li class="param">
                                
                                    <code class="param-name optional">[src]</code>
                                    <span class="type">String | Array</span>
                                    <span class="flag optional" title="This parameter is optional.">optional</span>
                                

                                <div class="param-description">
                                    <p>[ html,脚本或者样式路径,也可以是数组 ]</p>

                                </div>

                                
                            </li>
                            
                            <li class="param">
                                
                                    <code class="param-name optional">[successCallback]</code>
                                    <span class="type">Function</span>
                                    <span class="flag optional" title="This parameter is optional.">optional</span>
                                

                                <div class="param-description">
                                    <p>[ 1.5.4新增对ID的支持,结合html使用,查看例子5, 加载成功以后执行,如果是数组,只在最后一个执行 ]</p>

                                </div>

                                
                            </li>
                            
                        </ul>
                    
                </li>
            
            </ul>
        </div>
    

    
        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                
                    
                        <span class="type">Boolean</span>:
                    
                    <p>[ 全部创建完成以后会返回 true ]</p>

                
            </div>
        </div>
    

    
        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                <pre class="code prettyprint"><code>       例子1: 动态加载单个样式

       loader.import(&quot;main.css&quot;,function(src){
         // 创建成功以后执行回调
       });

       例子2: 动态加载单个脚本

       loader.import(&quot;main.js&quot;,function(src){
         // 创建成功以后执行回调
       });

       例子3: 动态加载多个脚本

       loader.import([&quot;js/plugins/baiduTemplate.js&quot;,&quot;js/plugins/map.js&quot;],function(src){
         // 创建成功以后执行回调
       });

       例子4: 1.5.2新增, 动态加载模板,回调每次都执行, 如果放在 loader.require 里面执行,则默认只初始化一次;

       loader.import(&quot;pages/ui/list.html&quot;,function(res){
         // 拿到模板信息
       });

       例子5: 1.5.4新增, 把html,渲染到某个id下,只渲染一次. 有回调也只执行一次

       loader.import(&quot;pages/ui/list.html&quot;,&quot;#id&quot;,function(res){
           // 在渲染模板到#id以后,回调只执行一次
       });</code></pre>

            </div>
        </div>
    
</div>

                
                    <div id="method_map" class="method item">
    <h3 class="name"><code>map</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code class="optional">[option]</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l82"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:82</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>设置或者获取模块之间的依赖关系</p>
<p>如果define了一个自定义名称的模块,则需要在首页用map方法,声明该模块的script或callback属性</p>
    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name optional">[option]</code>
                        <span class="type">Object</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                         
                    </div>

                    
                        <ul class="params-list">
                            
                            <li class="param">
                                
                                    <code class="param-name optional">[baseUrl]</code>
                                    <span class="type">String</span>
                                    <span class="flag optional" title="This parameter is optional.">optional</span>
                                

                                <div class="param-description">
                                    <p>[默认:&quot;&quot; 脚本资源的公共路径 ]</p>

                                </div>

                                
                            </li>
                            
                            <li class="param">
                                
                                    <code class="param-name optional">[modules]</code>
                                    <span class="type">Object</span>
                                    <span class="flag optional" title="This parameter is optional.">optional</span>
                                

                                <div class="param-description">
                                    <p>[默认:{} 模块的配置存放在modules对象中 ]</p>

                                </div>

                                
                                    <ul class="params-list">
                                        
                                        <li class="param">
                                            
                                                <code class="param-name optional">[main]</code>
                                                <span class="type">Object</span>
                                                <span class="flag optional" title="This parameter is optional.">optional</span>
                                            

                                            <div class="param-description">
                                                [默认:{} router路由默认定义了一个main模块 ]
                                            </div>
                                        </li>
                                        
                                        <li class="param">
                                            
                                                <code class="param-name">main.moduleName</code>
                                                <span class="type">String</span>
                                            

                                            <div class="param-description">
                                                [默认:"main" 当前模块的名称等于父级名 ]
                                            </div>
                                        </li>
                                        
                                        <li class="param">
                                            
                                                <code class="param-name">main.template</code>
                                                <span class="type">String</span>
                                            

                                            <div class="param-description">
                                                [默认:"" 模板名称,用于路由的模板加载 ]
                                            </div>
                                        </li>
                                        
                                        <li class="param">
                                            
                                                <code class="param-name">main.script</code>
                                                <span class="type">String</span>
                                            

                                            <div class="param-description">
                                                [默认:"" 当前模块的加载脚本 ]
                                            </div>
                                        </li>
                                        
                                        <li class="param">
                                            
                                                <code class="param-name optional">[main.style]</code>
                                                <span class="type">Array</span>
                                                <span class="flag optional" title="This parameter is optional.">optional</span>
                                            

                                            <div class="param-description">
                                                [默认:[] 加载模块的样式资源,也可以使用load方法单独加载]
                                            </div>
                                        </li>
                                        
                                        <li class="param">
                                            
                                                <code class="param-name optional">[main.depend]</code>
                                                <span class="type">Array</span>
                                                <span class="flag optional" title="This parameter is optional.">optional</span>
                                            

                                            <div class="param-description">
                                                [默认:[] 模块的依赖名,如果define时没有声明名称,则依赖名为该脚本的路径去掉.js ]
                                            </div>
                                        </li>
                                        
                                    </ul>
                                
                            </li>
                            
                        </ul>
                    
                </li>
            
            </ul>
        </div>
    

    

    
        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                <pre class="code prettyprint"><code>      例子1: 获取所有模块的配置信息
      var map = loader.map();

      例子2: 声明单个模块;

      loader.map({
          moduleName: &quot;main&quot;,
          template: &quot;pages/main/main.html&quot;,
          script: &quot;pages/main/main.js&quot;
      })

      例子3: 定义多个模块,并修改路径
      loader.map({
        baseUrl: &quot;&quot;,
        modules: {
          // 自定义模块名
          &quot;main&quot;: {
            moduleName: &quot;main&quot;,
            template: &quot;pages/main/main.html&quot;,
            script: &quot;pages/main/main.js&quot;
          }
        }
      })</code></pre>

            </div>
        </div>
    
</div>

                
                    <div id="method_require" class="method item">
    <h3 class="name"><code>require</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code class="optional">[option]</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    
        <span class="returns-inline">
            <span class="type">Object</span>
        </span>
    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l577"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:577</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>获取依赖的实例,异步,在同一次依赖加载里面,如果该实例已经重复初始化,不会重复执行.</p>
    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name optional">[option]</code>
                        <span class="type">Object</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                         
                    </div>

                    
                        <ul class="params-list">
                            
                            <li class="param">
                                
                                    <code class="param-name">depend</code>
                                    <span class="type">Array | String</span>
                                

                                <div class="param-description">
                                    <p>[模块的依赖模块,可以是数组或者模块名 ]</p>

                                </div>

                                
                            </li>
                            
                            <li class="param">
                                
                                    <code class="param-name">callback</code>
                                    <span class="type">Function</span>
                                

                                <div class="param-description">
                                    <p>[加载模块成功以后,执行回调 ]</p>

                                </div>

                                
                            </li>
                            
                        </ul>
                    
                </li>
            
            </ul>
        </div>
    

    
        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                
                    
                        <span class="type">Object</span>:
                    
                    <p>[ loader ]</p>

                
            </div>
        </div>
    

    
        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                <pre class="code prettyprint"><code>       例子1: 加载单个模块

       loader.require(&quot;main&quot;,function (main) {
         console.log(main)
       })

       例子2: 加载多个模块
       loader.require([&quot;main&quot;,&quot;page2&quot;],function (main,page2) {
         console.log(main)
         console.log(page2)
       })</code></pre>

            </div>
        </div>
    
</div>

                
                    <div id="method_set" class="method item">
    <h3 class="name"><code>set</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code>name</code>
                    
                </li>
            
                <li class="arg">
                    
                        <code>value</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l160"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:160</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>设置模块</p>
    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name">name</code>
                        <span class="type">String</span>
                    

                    

                    <div class="param-description">
                        <p>[ 模块名 ]</p>

                    </div>

                    
                </li>
            
                <li class="param">
                    
                        <code class="param-name">value</code>
                        <span class="type">Object</span>
                    

                    

                    <div class="param-description">
                        <p>[ 模块的路径 {template:&quot;&quot;,script:&quot;&quot;}]</p>

                    </div>

                    
                </li>
            
            </ul>
        </div>
    

    

    
        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                <pre class="code prettyprint"><code>       // 修改首页为登录页, 需要在window.router 后面
       loader.set(&quot;main&quot;,{
           template: &quot;pages/login/login.html&quot;,
           script: &quot;pages/login/login.html&quot;
       })</code></pre>

            </div>
        </div>
    
</div>

                
            </div>
        

        

        

        
            <div id="events" class="api-class-tabpanel">
                <h2 class="off-left">Events</h2>

                
                    <div id="event_off" class="events item">
    <h3 class="name"><code>off</code></h3>
    <span class="type"></span>

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l1161"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:1161</code></a>
        
        </p>

        

        
            <p>Available since 1.5.3</p>
        
    </div>

    <div class="description">
        <p>为控件取消绑定事件</p>

    </div>

    
        <div class="params">
            <h4>Event Payload:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name optional">[type]</code>
                        <span class="type">String</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                        <p>[关闭订阅事件 例如: success]</p>

                    </div>

                    
                </li>
            
                <li class="param">
                    
                        <code class="param-name optional">[callback]</code>
                        <span class="type">Function</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                        <p>[ 监听事件以后执行 ]</p>

                    </div>

                    
                </li>
            
            </ul>
        </div>
    


    
        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                <pre class="code prettyprint"><code>       loader.off(&quot;success&quot;);</code></pre>

            </div>
        </div>
    
</div>

                
                    <div id="event_on" class="events item">
    <h3 class="name"><code>on</code></h3>
    <span class="type"></span>

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l1140"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:1140</code></a>
        
        </p>

        

        
            <p>Available since 1.5.3</p>
        
    </div>

    <div class="description">
        <p>为模块绑定事件,比方依赖的模块是异步的,这个时候可以监听该数据请求结束以后再执行.</p>

    </div>

    
        <div class="params">
            <h4>Event Payload:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name optional">[type]</code>
                        <span class="type">String</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                        <p>[关闭订阅事件 例如: success ]</p>

                    </div>

                    
                </li>
            
                <li class="param">
                    
                        <code class="param-name optional">[callback]</code>
                        <span class="type">Function</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                        <p>[ 监听事件以后执行 ]</p>

                    </div>

                    
                </li>
            
            </ul>
        </div>
    


    
        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                <pre class="code prettyprint"><code>         loader.on(&quot;success&quot;,function () {
             // 点击的菜单
             console.log(this);
         });</code></pre>

            </div>
        </div>
    
</div>

                
                    <div id="event_trigger" class="events item">
    <h3 class="name"><code>trigger</code></h3>
    <span class="type"></span>

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/_Users_wilson_personal_htdocs_opensource_bui-rollup_src_scripts_core_bui.loader.js.html#l1178"><code>&#x2F;Users&#x2F;wilson&#x2F;personal&#x2F;htdocs&#x2F;opensource&#x2F;bui-rollup&#x2F;src&#x2F;scripts&#x2F;core&#x2F;bui.loader.js:1178</code></a>
        
        </p>

        

        
            <p>Available since 1.5.3</p>
        
    </div>

    <div class="description">
        <p>触发自定义事件</p>

    </div>

    
        <div class="params">
            <h4>Event Payload:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name optional">[type]</code>
                        <span class="type">String</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                        <p>[自定义事件, 例如: &quot;success&quot;]</p>

                    </div>

                    
                </li>
            
                <li class="param">
                    
                        <code class="param-name optional">[args]</code>
                        <span class="type">String</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                        <p>[传过去的参数,可以有多个 ]</p>

                    </div>

                    
                </li>
            
            </ul>
        </div>
    


    
        <div class="example">
            <h4>Example:</h4>

            <div class="example-content">
                <pre class="code prettyprint"><code>       bui.ajax({
           url: &quot;&quot;
       }).then(function(result){
           loader.trigger(&quot;success&quot;,result);
       })</code></pre>

            </div>
        </div>
    
</div>

                
            </div>
        
    </div>
</div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
<!-- 百度统计 -->
<script>
var _hmt = _hmt || [];
    (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?1e19beda5d47048a31939f0f67d9b1f9";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>


</body>
</html>
